package com.dofast.bt.bean;

import com.dofast.bt.base.BaseApplication;

import org.xutils.db.annotation.Column;
import org.xutils.db.annotation.Table;
import org.xutils.ex.DbException;

import java.util.List;

/**
 * Created by lcf on 2016/12/6 0006.
 * 茶铺
 */
@Table(name = "shop_nomal")
public class ShopBean {
    /**
     * name = "id"：数据库表中的一个字段
     * isId = true：是否是主键
     * autoGen = true：是否自动增长
     * property = "NOT NULL"：添加约束
     */
    @Column(name = "shopId",isId = true,property = "NOT NULL")
    private int shopId;//店铺id

    @Column(name = "name")
    private String name;//店铺名称

    @Column(name = "img_head")
    private String img_head;//店铺头像

    @Column(name = "img_bg")
    private String img_bg;//店铺背景图

    @Column(name = "content")
    private String content;//店铺介绍

    @Column(name = "concerns")
    private int concerns;//关注数量

    @Column(name = "flag")
    private String flag;//店铺标签（以顿号隔开，如：茶具、杯具）

    //默认的构造方法必须写出，如果没有，这张表是创建不成功的
    public ShopBean(){

    }
    public int getShopId() {
        return shopId;
    }

    public void setShopId(int shopId) {
        this.shopId = shopId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getImg_head() {
        return img_head;
    }

    public void setImg_head(String img_head) {
        this.img_head = img_head;
    }

    public String getImg_bg() {
        return img_bg;
    }

    public void setImg_bg(String img_bg) {
        this.img_bg = img_bg;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public int getConcerns() {
        return concerns;
    }

    public void setConcerns(int concerns) {
        this.concerns = concerns;
    }

    public String getFlag() {
        return flag;
    }

    public void setFlag(String flag) {
        this.flag = flag;
    }

    /**
     * 获取改店铺下的所有商品列表
     * @return 商品列表
     * @throws DbException
     */
    public List<GoodsBean> getGoodses() throws DbException {
        return BaseApplication.getDbManager().selector(GoodsBean.class).where("shopId","=",this.shopId).findAll();
    }
}
